package deliciouse.biz.impl;

import java.util.List;

import org.apache.ibatis.session.SqlSession;

import deliciouse.biz.UserBiz;
import deliciouse.dao.UserDao;
import deliciouse.entity.Users;
import deliciouse.util.MybatisUtil;

public class UserBizImpl implements UserBiz{

	@Override
	public Users userIsExist(String username) {
		SqlSession sess = MybatisUtil.OpenSession();
		try {
		UserDao dao = sess.getMapper(UserDao.class);
		Users user = dao.userIsExist(username);
		return user;
		} finally {
			sess.close();
		}
	}

	@Override
	public boolean addUser(Users user) {
		SqlSession sess = MybatisUtil.OpenSession();
		try {
		UserDao dao = sess.getMapper(UserDao.class);
		dao.addUser(user);
		sess.commit();
		return true;
		} finally {
			sess.close();
		}
	}

	@Override
	public Users userCheckIn(Users users) {
		SqlSession sess = MybatisUtil.OpenSession();
		try {
		UserDao dao = sess.getMapper(UserDao.class);
		Users user = dao.userCheckIn(users);
		return user;
		
		} finally {
			sess.close();
		}
	}

	@Override
	public Users fetchisAdmin(String username) {
		SqlSession sess = MybatisUtil.OpenSession();
		try {
		UserDao dao = sess.getMapper(UserDao.class);
		Users users =dao.fetchisAdmin(username);
		return users;
		} finally {
			sess.close();
		}
	}

}
